package com.ganinfo.common;

import java.util.ArrayList;
import java.util.List;

import com.xiaoleilu.hutool.json.JSONUtil;

/**
 * @ClassName: Result
 * @Description: 统一返回结果
 * @author: ruikanwang
 * @date: 2017年2月24日 下午3:51:59
 */
public class Result {
	
	private int returncode;
	private Object data;
	private Integer size;
	private String message;
	private String remark;
	
	//构造方法
	public Result(){}
	//有参构造方法
	public Result(int code,Object data,Integer size,String message,String remark){
		setReturncode(code);
		setData(data == null?"":data);
		setSize(size == null?0:size);
		setMessage(message == null?"":message);
		setRemark(remark == null?"":remark);
	}
	//有参构造方法
	public Result(int code,Object data,String message,String remark){
		setReturncode(code);
		setData(data);
		setMessage(message);
		setRemark(remark);
	}
	
	//将Relust对象转换为json字符串
	public String toJson(){
		return JSONUtil.toJsonStr(this);
	}
	//测试
	public static void main(String[] args) {
		List<String> data = new ArrayList<String>();
		data.add("问卷");
		data.add("问题");
		data.add("选项");
		Result r = new Result(0, data,0, "", "");
		System.out.println(r.toJson());
	}
	
	
	public int getReturncode() {
		return returncode;
	}
	public void setReturncode(int returncode) {
		this.returncode = returncode;
	}
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public Integer getSize() {
		return size;
	}
	public void setSize(Integer size) {
		this.size = size;
	}
	
}
